<?php

namespace app\common\model;

use think\Model;

class Device extends Model
{
    //用户设备
    static function userDevice($user_id){
        $list = Device::all(function($query) use($user_id){
            $query->field('ctrl_device.*,ctrl_user_device.user_id,ctrl_user_device.device_id')->join('ctrl_user_device','ctrl_user_device.device_id = ctrl_device.id')
                ->where(["ctrl_user_device.user_id"=>$user_id]);
        });
        return $list;
    }
    //用户设备ID
    static function userDeviceId($user_id){
        $me = new self();
        $list = $me ->join('ctrl_user_device','ctrl_user_device.device_id = ctrl_device.id')
            ->where(["ctrl_user_device.user_id"=>$user_id])->column('ctrl_device.id');
        return $list;
    }
}
